package com.ss.android.newmedia.message.a;

import android.app.Activity;
import android.app.WallpaperManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TextView;

import com.bytedance.common.utility.Logger;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.article.browser.R;
import com.ss.android.image.BaseImageManager;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.newmedia.message.q;

import org.json.JSONObject;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.Date;

public class a extends Activity {
    private static ImageLoader j;
    private View a;
    private View b;
    private ImageView c;
    private TextView d;
    private TextView e;
    private ImageView f;
    private TextView g;
    private TextView h;
    private ImageView i;
    private String k;

    public a() {

    }

    private static float a(float arg2) {
        return TypedValue.applyDimension(1, arg2, Resources.getSystem().getDisplayMetrics());
    }

    public static void a(Context arg1, Intent arg2) {
        if (arg1 != null) {
            try {
                arg2.setClass(arg1, a.class);
                arg2.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                arg1.startActivity(arg2);
            } catch (Throwable v0) {
                v0.printStackTrace();
            }
        }
    }

    private Drawable a() {
        Drawable v0_2;
        Drawable v1 = null;
        WallpaperManager v0 = WallpaperManager.getInstance(this.getApplicationContext());
        v0_2 = v1;
        if (v0 != null) {
            try {
                v0_2 = v0.getDrawable();
            } catch (Exception v0_1) {
                v0_1.printStackTrace();
            }
        }
        if (!(v0_2 instanceof BitmapDrawable)) {
            v0_2 = v1;
        }

        return v0_2;
    }

    private void a(Intent arg15) {
        int v13 = 8;
        if (arg15 != null && !arg15.getExtras().isEmpty()) {
            String v8 = arg15.getStringExtra("small_image_url");
            String v9 = arg15.getStringExtra("title");
            arg15.getStringExtra("time");
            String v10 = arg15.getStringExtra("text");
            this.k = arg15.getStringExtra("big_image_url");
            String v11 = arg15.getStringExtra("open_intent");
            int v12 = arg15.getIntExtra("notification_id", 0);
            com.ss.android.newmedia.message.i.a(this.getApplicationContext(), "lock_push_show", ((long) v12), -1, false, new JSONObject[0]);
            if (TextUtils.isEmpty(((CharSequence) v11))) {
                this.finish();
            } else {
                try {
                    b v1 = new b(this, v12, Intent.parseUri(v11, 0));
                    this.b.setOnClickListener(((View.OnClickListener) v1));
                    this.f.setOnClickListener(((View.OnClickListener) v1));
                    this.i.setOnClickListener(new com.ss.android.newmedia.message.a.c(this));
                } catch (Throwable v0) {
                    v0.printStackTrace();
                    this.finish();
                    return;
                }

                Drawable v0_1 = this.a();
                if (v0_1 != null) {
                    this.a.setBackgroundDrawable(v0_1);
                }

                this.b.setBackgroundColor(this.getResources().getColor(com.ss.android.article.browser.R.color.nz));
                if (!TextUtils.isEmpty(this.k)) {
                    this.b.getLayoutParams().height = ((int) a(56f));
                } else {
                    this.b.getLayoutParams().height = ((int) a(86f));
                }

                if (TextUtils.isEmpty(((CharSequence) v8))) {
                    this.c.setVisibility(v13);
                } else {
                    this.c.setVisibility(View.VISIBLE);
                    j.a(this.c, v8, v8);
                }

                if (TextUtils.isEmpty(this.k)) {
                    this.f.setVisibility(v13);
                } else {
                    this.f.setVisibility(View.VISIBLE);
                    j.a(this.f, this.k, this.k);
                }

                if (!TextUtils.isEmpty(((CharSequence) v9)) && !TextUtils.isEmpty(((CharSequence) v10))) {
                    this.d.setText(((CharSequence) v9));
                    this.e.setText(((CharSequence) v10));
                    TextView v1_1 = this.e;
                    int v0_2 = !TextUtils.isEmpty(this.k) ? 1 : 2;
                    v1_1.setMaxLines(v0_2);
                    this.a.setOnTouchListener(new d(this));
                    return;
                }

                this.finish();
            }
        } else {
            this.finish();
        }
    }

    protected void onCreate(Bundle arg7) {
        int v4 = 134217728;
        int v3 = 67108864;
        Window v0 = this.getWindow();
        if (Build.VERSION.SDK_INT >= 19) {
            v0.setFlags(v3, v3);
            v0.setFlags(v4, v4);
        }

        v0.addFlags(4718592);
        super.onCreate(arg7);
        if (Logger.debug()) {
            Logger.d("LockScreenNotificationActivity", "onCreate");
        }

        this.setContentView(com.ss.android.article.browser.R.layout.fa);
        this.a = this.findViewById(com.ss.android.article.browser.R.id.root);
        this.b = this.findViewById(com.ss.android.article.browser.R.id.content);
        this.c = this.findViewById(com.ss.android.article.browser.R.id.yr);
        this.d = this.findViewById(com.ss.android.article.browser.R.id.title);
        this.findViewById(com.ss.android.article.browser.R.id.time);
        this.e = this.findViewById(com.ss.android.article.browser.R.id.text);
        this.f = this.findViewById(com.ss.android.article.browser.R.id.yq);
        this.g = this.findViewById(com.ss.android.article.browser.R.id.yo);
        this.h = this.findViewById(com.ss.android.article.browser.R.id.yp);
        this.i = this.findViewById(com.ss.android.article.browser.R.id.j6);
        TaskInfo v2 = new TaskInfo();
        BaseImageManager v3_1 = new BaseImageManager(this.getApplicationContext());
        Resources v0_1 = this.getResources();
        j = new q(this.getApplicationContext(), v2, v3_1, v0_1.getDimensionPixelSize(R.dimen.gh), v0_1.getDimensionPixelSize(R.dimen.gg));
        this.a(this.getIntent());
        new WeakReference(this);
    }

    protected void onDestroy() {
        super.onDestroy();
        if (Logger.debug()) {
            Logger.d("LockScreenNotificationActivity", "onDestroy");
        }
    }

    protected void onNewIntent(Intent arg3) {
        super.onNewIntent(arg3);
        if (Logger.debug()) {
            Logger.d("LockScreenNotificationActivity", "onNewIntent");
        }

        this.a(arg3);
    }

    protected void onPause() {
        super.onPause();
    }

    protected void onResume() {
        super.onResume();
    }

    protected void onStart() {
        super.onStart();
        this.h.setText(new SimpleDateFormat("MM月dd日 EEEE").format(new Date()));
        this.g.setText(new SimpleDateFormat("hh:mm").format(new Date()));
    }

    protected void onStop() {
        super.onStop();
    }
}

